const app = getApp();
const baseUrl = app.globalData.baseUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shipId: null,
    phone: null,
    elements: [{
      name: '身体状态',
      cover_s: baseUrl +'/file/body_status3.jpg'
    }, {
      name: '训练计划',
        cover_s: baseUrl +'/file/train2.jpg'
    }, {
      name: '训练历程',
        cover_s: baseUrl +'/file/history1.jpg'
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    const shipId = wx.getStorageSync("shipId");
    const phone = wx.getStorageSync("traineePhone");
    this.setData({
      shipId,
      phone
    });
  },
  toDetail: function(e) {
    const that = this;
    const index = e.currentTarget.dataset.index;
    switch (index) {
      case 0:
        that.toBodyStatus();
        break;
      case 1:
        that.toCourseTrain();
        break;
      case 2:
        that.toTrainHistory();
        break;
    }
  },
  toBodyStatus: function() {
    wx.setStorageSync('traineePhone', this.data.phone);
    wx.navigateTo({
      url: '/pages/bodyStatus/bodyStatus',
    });
  },
  toTrainHistory: function() {
    wx.setStorageSync("phone", this.data.phone);
    wx.navigateTo({
      url: '/pages/trainHistory/trainHistory',
    });
  },
  toCourseTrain: function() {
    wx.setStorageSync("phone", this.data.phone);
    wx.navigateTo({
      url: '/pages/courseTrain/courseTrain',
    });
  }
})